#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
#include<stdbool.h>
#include<assert.h>


 struct TreeNode  {
      int val;
      struct TreeNode *left;
      struct TreeNode *right;
  };
 struct TreeNode *BuyNode(int n)
 {
     struct TreeNode* new = (struct TreeNode*)malloc(sizeof(struct TreeNode));
     if (new == NULL)
     {
         perror("malloc fault");
         return -1;
     }
     new->val = n;
     new->left = NULL;
     new->right = NULL;
     return new;
 }

void swap(struct TreeNode* rood, struct TreeNode*lef, struct TreeNode*righ)
{
    rood->left = righ;
    rood->right =lef;

}
//struct TreeNode* invertTree(struct TreeNode* root) {
//    if (root == NULL)
//    {
//        return;
//    }
//    swap(root, &root->left, &root->right);
//    return invertTree(root->left) && invertTree(root->right);
//}
struct TreeNode* BinaCreate()
{
    struct TreeNode* a1 = BuyNode(4);
    struct TreeNode* a2 = BuyNode(2);
    struct TreeNode* a3 = BuyNode(7);
    struct TreeNode* a4 = BuyNode(1);
    struct TreeNode* a5 = BuyNode(3);
    struct TreeNode* a6 = BuyNode(6);
    struct TreeNode* a7 = BuyNode(9);
    a1->left = a2, a1->right = a3;
    a2->left = a4, a2->right = a5;
    a3->left = a6, a3->right = a7;
    return a1;
}
int main()
{
    int a[] = { 4,2,7,1,3,6,9 };
    struct TreeNode* root= BinaCreate();
    swap(root,root->left,root->right);
	return 0;
}
 //int main()
 //{
 //    struct TreeNode a1 = {4,NULL,NULL};
 //    struct TreeNode a2 = { 2,NULL,NULL };
 //    struct TreeNode a3 = { 7,NULL,NULL };
 //    struct TreeNode a4 = { 1,NULL,NULL };
 //    struct TreeNode a5 = { 3,NULL,NULL };
 //    struct TreeNode a6 = { 6,NULL,NULL };
 //    struct TreeNode a7 = { 9,NULL,NULL };
 //    a1.left = &a2; a1.right = &a3;
 //    a2.left = &a4; a2.right = &a5;
 //    a3.left = &a6; a3.right = &a7;
 //    return 0;
 //}